package com.xh.bussiness.tiku.service;


import com.xh.bussiness.exam.bean.dto.ExerciseStudentQuestionDto;
import com.xh.bussiness.tiku.bean.dto.QuestionDto;
import com.xh.bussiness.tiku.bean.dto.QuestionTypeCountDto;
import com.xh.bussiness.tiku.bean.request.BatchSaveQuestionRequest;
import com.xh.bussiness.tiku.bean.request.QuestionQueryRequest;
import com.xh.bussiness.tiku.bean.request.QuestionSaveRequest;
import com.xh.bussiness.tiku.bean.request.QuestionVariantRequest;
import com.xh.bussiness.tiku.model.Question;
import com.xh.bussiness.tiku.model.QuestionImportLog;
import com.xh.core.bean.XhPage;
import com.xh.core.service.IBaseService;
import org.apache.ibatis.annotations.Param;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 试题表 服务类
 * </p>
 *
 * @author daiwei
 * @since 2019-01-14
 */
public interface IQuestionService extends IBaseService<Question> {

    /**
     * 新增试题
     * @param bean
     * @return
     */
    public QuestionDto addQuestion(QuestionSaveRequest bean);

    /**
     * 修改试题
     * @return
     */
    public String modifyQuestion(QuestionSaveRequest bean);

    /**
     * 删除试题
     * @param id
     * @return
     */
    public String deleteQuestion(String id);

    /**
     * 获取单题
     * @param id
     * @param version
     * @return
     */
    public QuestionDto getQuestion(String id,Integer version);

    /**
     * 获取单题
     * @param id
     * @param version
     * @param withRightAnswer
     * @return
     */
    public QuestionDto getQuestion(String id,Integer version,Boolean withRightAnswer,Boolean withKnowledge,Boolean withChapter,Boolean withChapterKnowledge,Boolean withQuestionSource);

    /**
     * 作业获取单题
     * @author 赵文博
     * @date 2021/5/8 14:35
     **/
    QuestionDto getPracticeQuestion(String id,Integer version,Boolean withRightAnswer,Boolean withKnowledge,Boolean withChapter,Boolean withChapterKnowledge,Boolean withQuestionSource);

    /**
     * 作业获取单题
     * @param id
     * @param version
     * @return
     */
    QuestionDto getPracticeQuestion(String id,Integer version);

    List<QuestionDto> getQuestionChild(String questionId);

    /**
     * 分页查询方法
     * @param page
     * @param bean
     * @return
     * @throws Exception 
     */
    public XhPage queryQuestionPage(XhPage page, QuestionQueryRequest bean) throws Exception;

    /**
     * 查询方法
     * @param bean
     * @return
     */
    public List queryQuestion(QuestionQueryRequest bean);

    /**
     * 随机查询方法
     * @param bean
     * @return
     */
    public List<String> queryQuesitonRandom(QuestionQueryRequest bean);

    /**
     * 导入word试题
     * @param path
     * @return
     */
    public List<QuestionDto> importWordQuestions(String path, HttpServletRequest request);

    public void initQuestionData();

    public void downloadQuestionDataRes();

	public List<QuestionDto> queryFromJY(String subject,List<String> ids) throws Exception;

	public XhPage<QuestionDto> querySimilar(XhPage page, QuestionQueryRequest bean) throws Exception;

	public List<QuestionDto> queryVariant(List<QuestionVariantRequest> beans) throws Exception;
	
	public QuestionDto addQuestion(QuestionDto bean);

    /**
     * 根据箐优网试题id查题
     * @param refId
     * @return
     */
    Question queryByRefId(String refId);

    /**
     * 批量下载试题
     * @param subjectId 学科id
     * @param quesId 试题id
     */
    String downloadQuestion(Integer downloadType,String subjectId ,String quesId,HttpServletRequest request) throws Exception;

    /**
     * 试题导入
     * @param filePath
     * @return
     */
    QuestionImportLog importQuestion(String subjectId,String subjectName,String filePath,String fileName, Integer schoolId, HttpServletRequest request);

    /**
     * 批量保存试题
     * @param request
     */
    String batchSaveQuestion(BatchSaveQuestionRequest request);

    QuestionDto formatQuestion(QuestionDto dto);

    /**
     * 根据md5和学科值查询试题
     * @param md5
     * @param subjectId
     * @return
     */
    Question queryByMd5AndSubject(String md5,String subjectId);

    /**
     *  编辑试题，重新格式化
     * @return
     */
    QuestionDto editQuestion(QuestionSaveRequest bean);

    Boolean editQuestionOptionArrangements(Question question);
    /**
     *  查询题目数量 按类型  学科  难度  知识点分组
     * @return
     */
    List<QuestionTypeCountDto> getQuestionByType(QuestionQueryRequest bean);

    List<QuestionDto> querySimilarQuestions(List<Map<String, String>> repeatInfos);

    void batchModifyQuestionUseCount(List<String> questionIdList,Integer addOrReduce);

    void addQuestion_syncData(QuestionSaveRequest question);

    List<ExerciseStudentQuestionDto> queryQuestionDetail(List<String> id,String paperId);
}
